package com.example.leavls.controller;

import com.example.leavls.mapper.LeaveMapper;
import com.example.leavls.pojo.Leaverecords;
import com.example.leavls.util.RespPageEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
public class UtilpageService {
@Resource
private LeaveMapper leaveMapper;

    @Transactional
    public RespPageEntity getAllUserByPage(Integer page, Integer size) {
        RespPageEntity pageEntity = new RespPageEntity();
        // 默认从0开始
        if (page != null && size != null) {
            page = (page - 1) * size;
        }
        // 获取当前也用户信息
        List<Leaverecords> leaverecords = leaveMapper.getAllbypage(page, size);
        pageEntity.setData(leaverecords);
        // 获取当前用户总量
        Long total = leaveMapper.getTotal();
        pageEntity.setTotal(total);
        return pageEntity;
    }
}
